package com.zzq.demo.hibernate.runner;

import com.zzq.demo.hibernate.entity.Model;
import com.zzq.demo.hibernate.service.ModelService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.data.jpa.provider.HibernateUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author : zhaoziqian
 * @description :
 * @date : 2019/9/12 10:23
 */
//@Order(99)
//@Component
public class StartUpRunner implements CommandLineRunner {

    @Resource
    private ModelService modelService;

    @Override
    public void run(String... args) throws Exception {
        List<Model> models = modelService.findAll();
        for (Model model : models) {
            model.setName(model.getNum() + "lalalalalal");
            modelService.updateModel(model.getId(),model);
        }
    }
}
